Repository navigation
Parse parameterized view calls with a database and non-literal arguments - #342
Merged
git-hulk merged 2 commits intoNov 13, 2026
Merged
Conversation
A parameterized view is called like a table function. Two parts of that
call were rejected:
- a database-qualified name, db.view(name = value)
- an argument that is an array or a query parameter, such as
ids = [1, 2] or id = {id:UInt64}
ClickHouse prints the qualified call as `db.view`(...) when it formats
a query. That form already parsed once the arguments did.
git-hulk
previously approved these changes
Nov 13, 2026
Member
|
@sharadgaur Can you resolve the conflict. |
…w-call-arguments # Conflicts: # parser/parser_test.go
git-hulk
approved these changes
Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A parameterized view, a
CREATE VIEWwhose query has{name:Type}placeholders, is called like a table function:
view(name = value). Theparser rejected two parts of that call.
db.view(name = value). A qualified namefollowed by
(was always read as a plain table.ids = [1, 2],id = {id:UInt64}orids = [{id:UInt64}]. A viewthat passes its own parameters to another parameterized view uses
this form.
ClickHouse prints the qualified call as
`db.view`(...)when itformats a query. That form goes through the unqualified path and parses
once the arguments do.
Validation against ClickHouse
Checked with
clickhouse local26.2.1 usingformatQuery, which parseswithout needing the view to exist. The parser agrees with ClickHouse on
every row, and each formatted output was fed back to ClickHouse and
parses.
SELECT id FROM ...)db.v(a = 1)db.v(a = {x:UInt64})db.v(a = {x:Array(UInt64)}, b = [{y:UInt64}], c = toDateTime64({z:String}, 3))db.v(a = [1, 2], b = [], c = -1, d = 1 + 1, e = now())`db.v`(a = {x:UInt64}, b = [1, 2])v(a = {x:UInt64}, b = [1, 2])db.v(a = {x:UInt64}) AS p, also on the right of a JOIN and in a subquerydb.v(),db.v(1, 2)db.v(a = {x})db.v(a = {'k': 1}),db.v(a = {})db.v(a = [1, ),db.v(a = ),db.v(a = 1db.v(a = 1)(b = 2)db.(a = 1),db.t (SELECT 1)A semantic check with a real view, also on 26.2.1:
Changes
parseTableExprbuilds aTableFunctionExprfor a qualified namefollowed by
(.Nameis theTableIdentifierin that case and staysan
Identfor an unqualified call, so existing output does not change.parseTableArgPrimaryExpraccepts[as an array and{as a queryparameter, reusing
parseArrayParamsandparseQueryParam.{is notread as a map literal here, because ClickHouse rejects
{'k': 1}.No AST type, visitor, walk or formatter change.
Not in this PR
FINALafter a table function call is still rejected with theexisting error. ClickHouse parses
db.v(a = 1) FINAL.a.b.c(x = 1), is still rejected. ClickHouse parsesit.
TableArgListExpr.End()returns the position of), not the positionafter it. That is existing behaviour for every table function call.
Tests
testdata/query/select_from_parameterized_view.sqlTestParser_InvalidSyntax.make testpasses.golangci-lintv1.53.3 (the CI version) reports nothing.